package org.flexspeedup.utils
{
import org.flexspeedup.model.ListOption;

/**
 * Static methods with utility functions
 */
public class Utils
{
    //----------------------------------
    //  randRange
    //----------------------------------
    /**
     * Returns a random <code>int</code> within a range
     */
    public static function randRange(min:int, max:int):int
    {
        return Math.floor(Math.random() * (1 + max - min)) + min;
    } 

    //----------------------------------
    //  parseListModel
    //----------------------------------
    /**
     * Parses an XML formatted to work with an IListModel
     * @return Array;
     */
    public static function parseListModel(listNode:XML):Array
    {
        var array:Array = [];
        for each (var listOption:XML in listNode.listOption)
            array.push(new ListOption
                (
                    listOption.@id,
                    listOption.name,
                    listOption.data
                )
            );
        return array;
    } 
}
}